#include "StdAfx.h"
#include "LabelHeader.h"
#include "Endiannes.h"

namespace MnistDigit
{

	std::istream& operator>> (std::istream& i, LabelHeader& labelHeader)
	{
		i.read( (char*)( &labelHeader), sizeof(labelHeader)) ;

		Endiannes::MSB2OS(labelHeader.m_magic_number);
		Endiannes::MSB2OS(labelHeader.m_number_of_items);
		if(labelHeader.m_magic_number!=2049 
			|| (labelHeader.m_number_of_items!=10000 && labelHeader.m_number_of_items!=60000))
			throw std::logic_error( "operator>> (std::istream& i, LabelHeader");

		return i;
	}
}